package com.ronri.ams.bean;

import com.ronri.common.StringManager;

import java.util.List;

public class sample_info extends VerifyData {

    private String mMessage = "";

    @Override
    public boolean verify() {
        // 判断用户
        if (getDetector_name().isEmpty()) {
            mMessage = "请选择用户。";
            return false;
        }

        if (getSample_breed() == null) {
            mMessage = "请添加样品信息。";
            return false;
        }

        if (getSample_breed().size() == 0) {
            mMessage = "请添加样品信息。";
            return false;
        }

        if (getUser_name().isEmpty()) {
            mMessage = "请选择用户。";
            return false;
        }

        if (getSection_name().isEmpty()) {
            mMessage = "请选择抽样环节。";
            return false;
        }

        if (getInspectd_name().isEmpty()) {
            mMessage = "请选择监测企业。";
            return false;
        }


        if (getSample_attach().size() <= 0) {
            mMessage = "请给样品拍照。";
            return false;
        }

        if (getSample_sign().size() <= 0) {
            mMessage = "请签名！";
            return false;
        }

        // 判断创建者
        return super.verify();
    }

    @Override
    public String GetErrorMessage() {
        return mMessage;
    }

    /**
     * create_user : 11
     * detector_id : 174
     * detector_name : 常州市
     * inspectd_unit : 17146
     * inspectd_name : 常州市
     * project_id : 54
     * sample_area : 3204
     * area_name : 常州市
     * sample_date : 2017-05-14 00:00:00
     * sample_user : 13,14,12
     * user_name : a,b,c
     * section : 2
     * section_name : 生产
     * section_type : 123
     * task_id : 30
     * sample_sign : [{"attach_name":"timg","attach_url":"http://localhost:8080/ams/upload/image/20170515/1494813701353.jpg","create_user":11,"upload_date":"2017-05-14 00:00:00","location":"123","longitude":"118.737346","latitude":"32.009726"}]
     * sample_attach : [{"attach_name":"timg","attach_url":"http://localhost:8080/ams/upload/image/20170515/1494813701353.jpg","create_user":11,"upload_date":"2017-05-14 00:00:00","location":"123","longitude":"118.737346","latitude":"32.009726","remark":"123"}]
     * sample_breed : [{"bar_code":"32","breed_id":1365,"breed_byname":"黄瓜","breed_base":"321","breed_number":"123","breed_source":"123","create_user":11,"remark":"","template_id":"1","sample_location":"武进区郑陆镇羌家村委中巷","breed_ext1":"1","breed_ext2":"2","breed_ext3":"3","breed_ext4":"4","breed_attach":[{"attach_name":"timg","attach_url":"http://localhost:8080/ams/upload/image/20170515/1494813701353.jpg","create_user":11,"upload_date":"2017-05-14 00:00:00","location":"123","longitude":"118.737346","latitude":"32.009726","remark":"123"}]},{"bar_code":"3333","breed_id":1365,"breed_byname":"黄瓜","breed_base":"321","breed_number":"123","breed_source":"123","create_user":11,"remark":"","template_id":"1","sample_location":"武进区郑陆镇羌家村委中巷","breed_ext1":"1","breed_ext2":"2","breed_ext3":"3","breed_ext4":"4","breed_attach":[{"attach_name":"timg","attach_url":"http://localhost:8080/ams/upload/image/20170515/1494813701353.jpg","create_user":11,"upload_date":"2017-05-14 00:00:00","location":"123","longitude":"118.737346","latitude":"32.009726","remark":"123"}]}]
     */

    public String szDefaultRegionCode;
    private int create_user;
    private int detector_id;
    private String detector_name;
    private int inspectd_unit;
    private String taskbreed;
    private String inspectd_name;
    private int project_id;
    private String project_name;
    private String sample_area;
    private String area_name;
    private String sample_date;
    private String sample_user;
    private String user_name;
    private String section;
    private String section_name;
    private int section_type;
    private int task_id;
    private String task_name;
    private int nature;
    private List<SampleSignBean> sample_sign;
    private List<SampleAttachBean> sample_attach;
    private List<SampleBreedBean> sample_breed;

    public void setNature(int nature){this.nature = nature;}
    public int getNature(){return nature;}

    public void setTaskbreed(String taskbreed) {
        this.taskbreed = taskbreed;
    }

    public String getProject_name() {
        return project_name;
    }

    public void setProject_name(String project_name) {
        this.project_name = project_name;
    }

    public String getTask_name() {
        return task_name;
    }

    public void setTask_name(String task_name) {
        this.task_name = task_name;
    }

    public String getTaskbreed() {
        return taskbreed;
    }

    public void setTaskBreed(String breed) {
        taskbreed = breed;
    }

    public int getCreate_user() {
        return create_user;
    }

    public void setCreate_user(int create_user) {
        this.create_user = create_user;
    }

    public int getDetector_id() {
        return detector_id;
    }

    public void setDetector_id(int detector_id) {
        this.detector_id = detector_id;
    }

    public String getDetector_name() {
        return detector_name;
    }

    public void setDetector_name(String detector_name) {
        this.detector_name = detector_name;
    }

    public int getInspectd_unit() {
        return inspectd_unit;
    }

    public void setInspectd_unit(int inspectd_unit) {
        this.inspectd_unit = inspectd_unit;
    }

    public String getInspectd_name() {
        return inspectd_name;
    }

    public void setInspectd_name(String inspectd_name) {
        this.inspectd_name = inspectd_name;
    }

    public int getProject_id() {
        return project_id;
    }

    public void setProject_id(int project_id) {
        this.project_id = project_id;
    }

    public String getSample_area() {
        return sample_area;
    }

    public void setSample_area(String sample_area) {
        this.sample_area = sample_area;
    }

    public String getArea_name() {
        return area_name;
    }

    public void setArea_name(String area_name) {
        this.area_name = area_name;
    }

    public String getSample_date() {
        return sample_date;
    }

    public void setSample_date(String sample_date) {
        this.sample_date = sample_date;
    }

    public String getSample_user() {
        return sample_user;
    }

    public void setSample_user(String sample_user) {
        this.sample_user = sample_user;
    }

    public String getUser_name() {
        return user_name;
    }

    public void setUser_name(String user_name) {
        this.user_name = user_name;
    }

    public String getSection() {
        return section;
    }

    public void setSection(String section) {
        this.section = section;
    }

    public String getSection_name() {
        return section_name;
    }

    public void setSection_name(String section_name) {
        this.section_name = section_name;
    }

    public int getSection_type() {
        return section_type;
    }

    public void setSection_type(int section_type) {
        this.section_type = section_type;
    }

    public int getTask_id() {
        return task_id;
    }

    public void setTask_id(int task_id) {
        this.task_id = task_id;
    }

    public List<SampleSignBean> getSample_sign() {
        return sample_sign;
    }

    public void setSample_sign(List<SampleSignBean> sample_sign) {
        this.sample_sign = sample_sign;
    }

    public List<SampleAttachBean> getSample_attach() {
        return sample_attach;
    }

    public void setSample_attach(List<SampleAttachBean> sample_attach) {
        this.sample_attach = sample_attach;
    }

    public List<SampleBreedBean> getSample_breed() {
        return sample_breed;
    }

    public void setSample_breed(List<SampleBreedBean> sample_breed) {
        this.sample_breed = sample_breed;
    }

    /***
     * 获取样品信息
     *
     * @return
     */
    public String GetSamplebreed() {

        if (sample_breed == null)
            return "";

        String szReturn = "";
        String szSplit = "";

        for (SampleBreedBean iTem : sample_breed) {
            szReturn += szSplit + iTem.breed_byname;
            szSplit = ",";
        }

        return szReturn;
    }

    public static class SampleSignBean {
        /**
         * attach_name : timg
         * attach_url : http://localhost:8080/ams/upload/image/20170515/1494813701353.jpg
         * create_user : 11
         * upload_date : 2017-05-14 00:00:00
         * location : 123
         * longitude : 118.737346
         * latitude : 32.009726
         */

        private String attach_name;
        private String attach_url;
        private int create_user;
        private String upload_date;
        private String location;
        private String longitude;
        private String latitude;

        public String getAttach_name() {
            return attach_name;
        }

        public void setAttach_name(String attach_name) {
            this.attach_name = attach_name;
        }

        public String getAttach_url() {
            return attach_url;
        }

        public void setAttach_url(String attach_url) {
            this.attach_url = attach_url;
        }

        public int getCreate_user() {
            return create_user;
        }

        public void setCreate_user(int create_user) {
            this.create_user = create_user;
        }

        public String getUpload_date() {
            return upload_date;
        }

        public void setUpload_date(String upload_date) {
            this.upload_date = upload_date;
        }

        public String getLocation() {
            return location;
        }

        public void setLocation(String location) {
            this.location = location;
        }

        public String getLongitude() {
            return longitude;
        }

        public void setLongitude(String longitude) {
            this.longitude = longitude;
        }

        public String getLatitude() {
            return latitude;
        }

        public void setLatitude(String latitude) {
            this.latitude = latitude;
        }
    }

    public static class SampleAttachBean {
        /**
         * attach_name : timg
         * attach_url : http://localhost:8080/ams/upload/image/20170515/1494813701353.jpg
         * create_user : 11
         * upload_date : 2017-05-14 00:00:00
         * location : 123
         * longitude : 118.737346
         * latitude : 32.009726
         * remark : 123
         */

        private String attach_name;
        private String attach_url;
        private int create_user;
        private String upload_date;
        private String location;
        private String longitude;
        private String latitude;
        private String remark;

        public String getAttach_name() {
            return attach_name;
        }

        public void setAttach_name(String attach_name) {
            this.attach_name = attach_name;
        }

        public String getAttach_url() {
            return attach_url;
        }

        public void setAttach_url(String attach_url) {
            this.attach_url = attach_url;
        }

        public int getCreate_user() {
            return create_user;
        }

        public void setCreate_user(int create_user) {
            this.create_user = create_user;
        }

        public String getUpload_date() {
            return upload_date;
        }

        public void setUpload_date(String upload_date) {
            this.upload_date = upload_date;
        }

        public String getLocation() {
            return location;
        }

        public void setLocation(String location) {
            this.location = location;
        }

        public String getLongitude() {
            return longitude;
        }

        public void setLongitude(String longitude) {
            this.longitude = longitude;
        }

        public String getLatitude() {
            return latitude;
        }

        public void setLatitude(String latitude) {
            this.latitude = latitude;
        }

        public String getRemark() {
            return remark;
        }

        public void setRemark(String remark) {
            this.remark = remark;
        }
    }

    public static class SampleBreedBean {

        private String mMessage = "";

        public boolean Verify() {

            mMessage = "";


            if (StringManager.isEmpty(getBar_code())) {
                mMessage = "请输入样品条码。";
                return false;
            }

            if (StringManager.isEmpty(getBreed_number())) {
                mMessage = "请输入样品数量。";
                return false;
            }

            if (StringManager.isEmpty(getBreed_base())) {
                mMessage = "请输入样品基数。";
                return false;
            }

            if (StringManager.isEmpty(getSample_location())) {
                mMessage = "请选择抽样地点。";
                return false;
            }

            if (StringManager.isEmpty(getBreed_source())) {
                mMessage = "请选择样品来源。";
                return false;
            }

            // 判断创建者
            return true;
        }

        public String GetErrorMessage() {
            return mMessage;
        }

        /**
         * bar_code : 32
         * breed_id : 1365
         * breed_byname : 黄瓜
         * breed_base : 321
         * breed_number : 123
         * breed_source : 123
         * create_user : 11
         * remark :
         * template_id : 1
         * sample_location : 武进区郑陆镇羌家村委中巷
         * breed_ext1 : 1
         * breed_ext2 : 2
         * breed_ext3 : 3
         * breed_ext4 : 4
         * breed_attach : [{"attach_name":"timg","attach_url":"http://localhost:8080/ams/upload/image/20170515/1494813701353.jpg","create_user":11,"upload_date":"2017-05-14 00:00:00","location":"123","longitude":"118.737346","latitude":"32.009726","remark":"123"}]
         */

        private String bar_code = "";
        private int breed_id = 0;
        private String breed_byname = "";
        private String breed_base = "";
        private String breed_number = "";
        private String breed_source = "";
        private int create_user = 0;
        private String remark = "";
        private String template_id = "";
        private String sample_location = "";
        private String breed_ext1 = "";
        private String breed_ext2 = "";
        private String breed_ext3 = "";
        private String breed_ext4 = "";
        private String breed_ext5 = "";
        private List<BreedAttachBean> breed_attach;

        public String getBar_code() {
            return bar_code;
        }

        public void setBar_code(String bar_code) {
            this.bar_code = bar_code;
        }

        public int getBreed_id() {
            return breed_id;
        }

        public void setBreed_id(int breed_id) {
            this.breed_id = breed_id;
        }

        public String getBreed_byname() {
            return breed_byname;
        }

        public void setBreed_byname(String breed_byname) {
            this.breed_byname = breed_byname;
        }

        public String getBreed_base() {
            return breed_base;
        }

        public void setBreed_base(String breed_base) {
            this.breed_base = breed_base;
        }

        public String getBreed_number() {
            return breed_number;
        }

        public void setBreed_number(String breed_number) {
            this.breed_number = breed_number;
        }

        public String getBreed_source() {
            return breed_source;
        }

        public void setBreed_source(String breed_source) {
            this.breed_source = breed_source;
        }

        public int getCreate_user() {
            return create_user;
        }

        public void setCreate_user(int create_user) {
            this.create_user = create_user;
        }

        public String getRemark() {
            return remark;
        }

        public void setRemark(String remark) {
            this.remark = remark;
        }

        public String getTemplate_id() {
            return template_id;
        }

        public void setTemplate_id(String template_id) {
            this.template_id = template_id;
        }

        public String getSample_location() {
            return sample_location;
        }

        public void setSample_location(String sample_location) {
            this.sample_location = sample_location;
        }

        public String getBreed_ext1() {
            return breed_ext1;
        }

        public void setBreed_ext1(String breed_ext1) {
            this.breed_ext1 = breed_ext1;
        }

        public String getBreed_ext2() {
            return breed_ext2;
        }

        public void setBreed_ext2(String breed_ext2) {
            this.breed_ext2 = breed_ext2;
        }

        public String getBreed_ext3() {
            return breed_ext3;
        }

        public void setBreed_ext3(String breed_ext3) {
            this.breed_ext3 = breed_ext3;
        }

        public String getBreed_ext4() {
            return breed_ext4;
        }

        public void setBreed_ext5(String breed_ext4) {
            this.breed_ext5 = breed_ext4;
        }

        public String getBreed_ext5() {
            return breed_ext5;
        }

        public void setBreed_ext4(String breed_ext4) {
            this.breed_ext4 = breed_ext4;
        }

        public List<BreedAttachBean> getBreed_attach() {
            return breed_attach;
        }

        public void setBreed_attach(List<BreedAttachBean> breed_attach) {
            this.breed_attach = breed_attach;
        }

        public static class BreedAttachBean {
            /**
             * attach_name : timg
             * attach_url : http://localhost:8080/ams/upload/image/20170515/1494813701353.jpg
             * create_user : 11
             * upload_date : 2017-05-14 00:00:00
             * location : 123
             * longitude : 118.737346
             * latitude : 32.009726
             * remark : 123
             */

            private String attach_name;
            private String attach_url;
            private int create_user;
            private String upload_date;
            private String location;
            private String longitude;
            private String latitude;
            private String remark;

            public String getAttach_name() {
                return attach_name;
            }

            public void setAttach_name(String attach_name) {
                this.attach_name = attach_name;
            }

            public String getAttach_url() {
                return attach_url;
            }

            public void setAttach_url(String attach_url) {
                this.attach_url = attach_url;
            }

            public int getCreate_user() {
                return create_user;
            }

            public void setCreate_user(int create_user) {
                this.create_user = create_user;
            }

            public String getUpload_date() {
                return upload_date;
            }

            public void setUpload_date(String upload_date) {
                this.upload_date = upload_date;
            }

            public String getLocation() {
                return location;
            }

            public void setLocation(String location) {
                this.location = location;
            }

            public String getLongitude() {
                return longitude;
            }

            public void setLongitude(String longitude) {
                this.longitude = longitude;
            }

            public String getLatitude() {
                return latitude;
            }

            public void setLatitude(String latitude) {
                this.latitude = latitude;
            }

            public String getRemark() {
                return remark;
            }

            public void setRemark(String remark) {
                this.remark = remark;
            }
        }
    }

    @Override
    public String toString() {
        return "sample_info{" +
                ", szDefaultRegionCode='" + szDefaultRegionCode + '\'' +
                ", create_user=" + create_user +
                ", detector_id=" + detector_id +
                ", detector_name='" + detector_name + '\'' +
                ", inspectd_unit=" + inspectd_unit +
                ", taskbreed='" + taskbreed + '\'' +
                ", inspectd_name='" + inspectd_name + '\'' +
                ", project_id=" + project_id +
                ", project_name='" + project_name + '\'' +
                ", sample_area='" + sample_area + '\'' +
                ", area_name='" + area_name + '\'' +
                ", sample_date='" + sample_date + '\'' +
                ", sample_user='" + sample_user + '\'' +
                ", user_name='" + user_name + '\'' +
                ", section='" + section + '\'' +
                ", section_name='" + section_name + '\'' +
                ", section_type=" + section_type +
                ", task_id=" + task_id +
                ", task_name='" + task_name + '\'' +
                ", nature=" + nature +
                ", sample_sign=" + sample_sign +
                ", sample_attach=" + sample_attach +
                ", sample_breed=" + sample_breed +
                '}';
    }
}
